package com.example.client.api;

import com.example.server.service.ManagerService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;

@Controller
@RequestMapping("/manager")
@CrossOrigin
@Slf4j
public class ManagerController {
    @Resource
    private ManagerService managerService;

    @CrossOrigin
    @GetMapping("/login")
    @ResponseBody
    public HashMap<String,Object> login(String id, String passwd){
        HashMap<String,Object> result = new HashMap<>();
        String r= managerService.login(id,passwd);
        log.info("登录账号:"+id+",登录密码："+passwd+",登录结果："+r);
        result.put("result",r);
        return result;
    }
    @CrossOrigin
    @GetMapping("/sign")
    @ResponseBody
    public  String sign(String id,String passwd){
        return managerService.sign(id,passwd);
    }
}
